require File.join(File.dirname(__FILE__), 'dump.rb')
require File.join(File.dirname(__FILE__), 'memcache-entry-serializer.rb')

class Exporter
    def initialize(address, filename)
        @address = address
        @filename = filename
    end

    def export
        srcCache = MemCache.new(@address)
        File.open(@filename, "wb") do |f|
            srcCache.slocs.each do |sloc|
                srcCache.keys(sloc).each do |key|
                    key, flags, value = srcCache.fetchDetails(key)
		    if key != nil then
                    f << Serializer.serialize(key, flags, value)
		    end
                end
            end
        end
    end
end
